use apilogger::config::Config;
use std::net::SocketAddr;

#[test]
fn test_config_loading() {
    let config = Config::new().expect("Failed to load configuration");
    
    // 测试服务器配置
    assert_eq!(
        config.server.address,
        "127.0.0.1:3000".parse::<SocketAddr>().unwrap()
    );
    
    // 测试端点配置 - 已更新为8个端点
    assert_eq!(config.endpoints.len(), 8);
    
    // 测试第一个端点
    let first_endpoint = &config.endpoints[0];
    assert_eq!(first_endpoint.path, "/api/test");
    assert_eq!(first_endpoint.methods, vec!["GET", "POST"]);
    
    // 测试第二个端点
    let second_endpoint = &config.endpoints[1];
    assert_eq!(second_endpoint.path, "/api/data");
    assert_eq!(
        second_endpoint.methods,
        vec!["GET", "POST", "PUT", "DELETE"]
    );
    
    // 测试错误端点
    let unauthorized_endpoint = &config.endpoints[2];
    assert_eq!(unauthorized_endpoint.path, "/api/unauthorized");
    assert_eq!(unauthorized_endpoint.methods, vec!["GET", "POST"]);
    
    // 测试认证端点
    let auth_endpoint = &config.endpoints[3];
    assert_eq!(auth_endpoint.path, "/api/auth/login");
    assert_eq!(auth_endpoint.methods, vec!["POST"]);
    
    // 测试日志配置
    assert_eq!(config.logging.level, "info");
    assert_eq!(config.logging.rotation.strategy, "daily");
    assert_eq!(config.logging.rotation.max_files, 7);
    assert_eq!(config.logging.directory, "logs");
} 